import argparse
from web_server_function.UserServer import user_server
from web_server_function.ServerUtils import server_utils
from utils.ReadUtil import read_util

# if __name__ == '__main__':
#     # 超管登录
#     server_utils.login_background("15917614074", "123456")
#     # 获取用户rsNo
#     rsNo = user_server.get_user_info_rsNo("13800000020")
#     print(f"用户rsno号为{rsNo}")
#     # 执行修改手机号操作
#     resp = user_server.update_user_phone(rsNo, "13800000020", "13800000021")
#     print(resp)

def main(old_phone_number, new_phone_number):
    # 超管登录
    server_utils.login_background(read_util.read_data()['后台账号密码']['超管账号'],
                                  read_util.read_data()['后台账号密码']['超管密码'])
    # 获取用户rsNo
    rsNo = user_server.get_user_info_rsNo(old_phone_number)
    print(f"用户rsno号为{rsNo}")
    # 执行修改手机号操作
    resp = user_server.update_user_phone(rsNo, old_phone_number, new_phone_number)
    print(resp)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='执行用户修改手机号操作')
    parser.add_argument('old_phone_number', type=str, help='用户老手机号')
    parser.add_argument('new_phone_number', type=str, help='用户新手机号')
    args = parser.parse_args()

    main(args.old_phone_number, args.new_phone_number)
